package com.timetable;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.easylib.base.BaseActivity;
import com.easylib.utils.ToastUtils;

import butterknife.Bind;
import butterknife.OnClick;

public class InputActivity extends BaseActivity {

    @Bind(R.id.tv_back)
    TextView tvBack;
    @Bind(R.id.tv_title)
    TextView tvTitle;
    @Bind(R.id.tv_submit)
    TextView tvSubmit;
    @Bind(R.id.et_title)
    EditText etTitle;
    @Bind(R.id.et_content)
    EditText etContent;
    @Bind(R.id.activity_refuse)
    LinearLayout activityRefuse;
    private int type;

    @Override
    public int getContentViewId() {
        return R.layout.activity_input;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
    }

    @Override
    protected void initVariable() {
        type = getIntent().getIntExtra("type",0);

    }

    @Override
    protected void processLogic(Bundle savedInstanceState) {
        if (type==0){
            tvTitle.setText("添加班级通知");
            etTitle.setHint("班级名称");
        }else{
            tvTitle.setText("添加部门通知");
            etTitle.setHint("部门名称");
        }


    }

    private String title,content;
    @OnClick({R.id.tv_back, R.id.tv_submit})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_back:
                finish();
                break;
            case R.id.tv_submit:
                title=etTitle.getText().toString().trim();
                content=etContent.getText().toString().trim();
                if (!TextUtils.isEmpty(title)&&!TextUtils.isEmpty(content)){
                    ToastUtils.showToast("添加成功");
                    Intent intent=new Intent(mContext,MemorandumActivity.class);
                    intent.putExtra("title",title);
                    intent.putExtra("content",content);
                    setResult(RESULT_OK,intent);
                    finish();
                }else {
                    ToastUtils.showToast("请填写标题和内容，别空着");
                }

                break;
        }
    }
}
